package beans;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

import daos.AlumnoDAO;
import daosimp.AlumnoDAOIMP;
import modelo.Alumno;
import modelo.Persona;

@ManagedBean
@RequestScoped
public class AlumnoBean {

	private Alumno alumno;
	private AlumnoDAO alumnoDAO = new AlumnoDAOIMP();

	public Alumno getAlumno() {
		return alumno;
	}

	public void setAlumno(Alumno alumno) {
		this.alumno = alumno;
	}

	public boolean verificarSesion() {
		boolean estado = false;
		Persona per = (Persona) FacesContext.getCurrentInstance()
				.getExternalContext().getSessionMap().get("persona");
		if (per != null) {
			if (per.getRolPersona() == 1) {
				alumno = alumnoDAO.obtenerAlumnoxPersona(per);
				estado = true;
			}
		}
		return estado;
	}

}
